package com.lqzs.businessmanager.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.lqzs.businessmanager.bean.EleInfo

@Dao
interface EleDao {

    @Query("SELECT * FROM ele_table")
    suspend fun getAll(): MutableList<EleInfo>

    @Query("""SELECT * FROM ele_table WHERE ele_userName = :userName AND ele_fraction = :fraction AND ele_chaseComments = :chaseComments AND ele_orderDetails = :orderDetails AND ele_chaseComments_time = :chaseCommentsTime""")
    fun findEleInfo(
        userName: String?,
        fraction: String?,
        chaseComments: String?,
        orderDetails: String?,
        chaseCommentsTime: String?
    ): MutableList<EleInfo>?

    @Query("SELECT * FROM ele_table WHERE ele_reviewId = :reviewId")
    suspend fun queryForId(reviewId:String): EleInfo?

    @Query("SELECT * FROM ele_table WHERE ele_upload = 0 OR ele_upload=3")
    suspend fun queryNoUpload(): MutableList<EleInfo>

    @Query("SELECT * FROM ele_table WHERE ele_upload = 1 ")
    suspend fun queryUpload(): MutableList<EleInfo>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertOrUpdate(eleInfo: EleInfo)

    @Insert
    suspend fun insertAll(eleInfo: EleInfo)

    @Delete
    suspend fun delete(eleInfo: EleInfo)

    @Update
    suspend fun update(eleInfo: EleInfo)
}